package org.ecype.diego;

import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

public class RecreateTableOnUpdate implements UpdateCallback {

	@Override
	public void onUpdate(Entity entity, SQLiteDatabase db, int oldVersion, int newVersion) {
		String sql = "DROP TABLE IF EXISTS " + entity.getName();
        Log.d("SQL", sql.toString());
        db.execSQL(sql.toString());
        
        EntityToSqlConverter entityToSqlConverter = new EntityToSqlConverter();
        sql = entityToSqlConverter.getCreateTableSql(entity);
		Log.d("SQL", sql);
		db.execSQL(sql);
	}


}
